package com.ahsjdy.stcommon.dto;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

@Setter
@Getter
public class LonLatDTO {

    public LonLatDTO() {

    }

    public LonLatDTO(String lon, String lat) {
        this.lon = lon;
        this.lat = lat;
        this.lonD = Double.parseDouble(lon);
        this.latD = Double.parseDouble(lat);
    }

    public LonLatDTO(double lonD, double latD) {
        this.lonD = lonD;
        this.latD = latD;
        this.lon = String.valueOf(lonD);
        this.lat = String.valueOf(latD);
    }

    /**
     * 经度
     */
    private String lon;

    /**
     * 纬度
     */
    private String lat;

    private double lonD;

    private double latD;

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }

        if (obj instanceof LonLatDTO) {
            LonLatDTO dto = (LonLatDTO) obj;
            if (dto.getLat().equals(this.getLat()) && dto.getLon().equals(this.getLon())) {
                return true;
            }
        }

        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(lon, lat);
    }
}
